<?php
class Newsletter {
	var $id = null;
	var $email = null;
	var $subject = null;
	var $content = null;
	
	function viewAll() {
		$query = "select * from dt_newsletter";
		$data = mysql_query($query);
		return $data;
	} 
	
	function selectSingle($id) {
		$query = "select * from dt_newsletter where n_id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function update($id, $subject, $content) {
		$query = "update dt_newsletter set n_subject = '$subject', n_content = '$content' where n_id = '$id'";
		mysql_query($query);
	}
	
	function insert($subject, $content) {
		$query = "insert into dt_newsletter (n_subject, n_content) values ('$subject', '$content')";
		mysql_query($query);		
	}
	
	function delete($id) {
		$query = "delete from dt_newsletter where n_id = '$id'";
		mysql_query($query);
	}
	
	/*
	 * newsletter emails functions 
	 */
	
	function viewAllUsers() {
		$query = "select * from dt_newsletter_emails";
		$data = mysql_query($query);
		return $data;
	}
	
	function selectSingleUsers($id) {
		$query = "select * from dt_newsletter_emails where nl_id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function updateUsers($id, $email) {
		$query = "update dt_newsletter_emails set nl_email = '$email' where nl_id = '$id'";
		mysql_query($query);
	}
	
	function insertUsers($email) {
		$query = "insert into dt_newsletter_emails (nl_email) values ('$email')";
		mysql_query($query);
	}
	
	function deleteUsers($id) {
		$query = "delete from dt_newsletter_emails where nl_id = '$id'";
		mysql_query($query);
	}
}
?>